{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# A PyTorch *Hello, World!*"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/the-deep-learners/deep-learning-illustrated/blob/master/notebooks/pytorch.ipynb)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import torch"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "x = torch.zeros(28, 28, 1, dtype=torch.uint8)\n",
    "y = torch.randn(28, 28, 1, dtype=torch.float32)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "torch.Size([28, 28, 1])\n",
      "torch.uint8\n",
      "torch.Size([28, 28, 1])\n",
      "torch.float32\n"
     ]
    }
   ],
   "source": [
    "print(x.shape)\n",
    "print(x.dtype)\n",
    "print(y.shape)\n",
    "print(y.dtype)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([[32., 32., 32.],\n",
      "        [32., 32., 32.],\n",
      "        [32., 32., 32.]])\n"
     ]
    }
   ],
   "source": [
    "x = torch.zeros(3, 3, dtype=torch.float32, requires_grad=True)\n",
    "\n",
    "y = x - 4\n",
    "z = y**3 * 6\n",
    "out = z.mean()\n",
    "\n",
    "out.backward()\n",
    "\n",
    "print(x.grad)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Step:    1 - loss: 2.3263\n",
      "Step:    2 - loss: 2.1633\n",
      "Step:    3 - loss: 2.0075\n",
      "Step:    4 - loss: 1.8599\n",
      "Step:    5 - loss: 1.7213\n",
      "Step:    6 - loss: 1.5918\n",
      "Step:    7 - loss: 1.4717\n",
      "Step:    8 - loss: 1.3607\n",
      "Step:    9 - loss: 1.2586\n",
      "Step:   10 - loss: 1.1650\n",
      "Step:   11 - loss: 1.0794\n",
      "Step:   12 - loss: 1.0011\n",
      "Step:   13 - loss: 0.9297\n",
      "Step:   14 - loss: 0.8646\n",
      "Step:   15 - loss: 0.8052\n",
      "Step:   16 - loss: 0.7509\n",
      "Step:   17 - loss: 0.7013\n",
      "Step:   18 - loss: 0.6558\n",
      "Step:   19 - loss: 0.6141\n",
      "Step:   20 - loss: 0.5758\n",
      "Step:   21 - loss: 0.5406\n",
      "Step:   22 - loss: 0.5081\n",
      "Step:   23 - loss: 0.4780\n",
      "Step:   24 - loss: 0.4502\n",
      "Step:   25 - loss: 0.4245\n",
      "Step:   26 - loss: 0.4005\n",
      "Step:   27 - loss: 0.3783\n",
      "Step:   28 - loss: 0.3576\n",
      "Step:   29 - loss: 0.3383\n",
      "Step:   30 - loss: 0.3204\n",
      "Step:   31 - loss: 0.3036\n",
      "Step:   32 - loss: 0.2880\n",
      "Step:   33 - loss: 0.2733\n",
      "Step:   34 - loss: 0.2597\n",
      "Step:   35 - loss: 0.2469\n",
      "Step:   36 - loss: 0.2350\n",
      "Step:   37 - loss: 0.2238\n",
      "Step:   38 - loss: 0.2133\n",
      "Step:   39 - loss: 0.2035\n",
      "Step:   40 - loss: 0.1943\n",
      "Step:   41 - loss: 0.1857\n",
      "Step:   42 - loss: 0.1776\n",
      "Step:   43 - loss: 0.1700\n",
      "Step:   44 - loss: 0.1629\n",
      "Step:   45 - loss: 0.1562\n",
      "Step:   46 - loss: 0.1499\n",
      "Step:   47 - loss: 0.1440\n",
      "Step:   48 - loss: 0.1384\n",
      "Step:   49 - loss: 0.1331\n",
      "Step:   50 - loss: 0.1282\n",
      "Step:   51 - loss: 0.1235\n",
      "Step:   52 - loss: 0.1191\n",
      "Step:   53 - loss: 0.1149\n",
      "Step:   54 - loss: 0.1110\n",
      "Step:   55 - loss: 0.1073\n",
      "Step:   56 - loss: 0.1037\n",
      "Step:   57 - loss: 0.1004\n",
      "Step:   58 - loss: 0.0972\n",
      "Step:   59 - loss: 0.0942\n",
      "Step:   60 - loss: 0.0914\n",
      "Step:   61 - loss: 0.0887\n",
      "Step:   62 - loss: 0.0861\n",
      "Step:   63 - loss: 0.0836\n",
      "Step:   64 - loss: 0.0813\n",
      "Step:   65 - loss: 0.0791\n",
      "Step:   66 - loss: 0.0769\n",
      "Step:   67 - loss: 0.0749\n",
      "Step:   68 - loss: 0.0730\n",
      "Step:   69 - loss: 0.0711\n",
      "Step:   70 - loss: 0.0694\n",
      "Step:   71 - loss: 0.0677\n",
      "Step:   72 - loss: 0.0660\n",
      "Step:   73 - loss: 0.0645\n",
      "Step:   74 - loss: 0.0630\n",
      "Step:   75 - loss: 0.0616\n",
      "Step:   76 - loss: 0.0602\n",
      "Step:   77 - loss: 0.0589\n",
      "Step:   78 - loss: 0.0576\n",
      "Step:   79 - loss: 0.0564\n",
      "Step:   80 - loss: 0.0552\n",
      "Step:   81 - loss: 0.0540\n",
      "Step:   82 - loss: 0.0530\n",
      "Step:   83 - loss: 0.0519\n",
      "Step:   84 - loss: 0.0509\n",
      "Step:   85 - loss: 0.0499\n",
      "Step:   86 - loss: 0.0489\n",
      "Step:   87 - loss: 0.0480\n",
      "Step:   88 - loss: 0.0471\n",
      "Step:   89 - loss: 0.0463\n",
      "Step:   90 - loss: 0.0454\n",
      "Step:   91 - loss: 0.0446\n",
      "Step:   92 - loss: 0.0439\n",
      "Step:   93 - loss: 0.0431\n",
      "Step:   94 - loss: 0.0424\n",
      "Step:   95 - loss: 0.0416\n",
      "Step:   96 - loss: 0.0410\n",
      "Step:   97 - loss: 0.0403\n",
      "Step:   98 - loss: 0.0396\n",
      "Step:   99 - loss: 0.0390\n",
      "Step:  100 - loss: 0.0384\n",
      "Step:  101 - loss: 0.0378\n",
      "Step:  102 - loss: 0.0372\n",
      "Step:  103 - loss: 0.0366\n",
      "Step:  104 - loss: 0.0361\n",
      "Step:  105 - loss: 0.0355\n",
      "Step:  106 - loss: 0.0350\n",
      "Step:  107 - loss: 0.0345\n",
      "Step:  108 - loss: 0.0340\n",
      "Step:  109 - loss: 0.0335\n",
      "Step:  110 - loss: 0.0330\n",
      "Step:  111 - loss: 0.0326\n",
      "Step:  112 - loss: 0.0321\n",
      "Step:  113 - loss: 0.0317\n",
      "Step:  114 - loss: 0.0312\n",
      "Step:  115 - loss: 0.0308\n",
      "Step:  116 - loss: 0.0304\n",
      "Step:  117 - loss: 0.0300\n",
      "Step:  118 - loss: 0.0296\n",
      "Step:  119 - loss: 0.0292\n",
      "Step:  120 - loss: 0.0289\n",
      "Step:  121 - loss: 0.0285\n",
      "Step:  122 - loss: 0.0281\n",
      "Step:  123 - loss: 0.0278\n",
      "Step:  124 - loss: 0.0274\n",
      "Step:  125 - loss: 0.0271\n",
      "Step:  126 - loss: 0.0268\n",
      "Step:  127 - loss: 0.0265\n",
      "Step:  128 - loss: 0.0261\n",
      "Step:  129 - loss: 0.0258\n",
      "Step:  130 - loss: 0.0255\n",
      "Step:  131 - loss: 0.0252\n",
      "Step:  132 - loss: 0.0249\n",
      "Step:  133 - loss: 0.0246\n",
      "Step:  134 - loss: 0.0244\n",
      "Step:  135 - loss: 0.0241\n",
      "Step:  136 - loss: 0.0238\n",
      "Step:  137 - loss: 0.0236\n",
      "Step:  138 - loss: 0.0233\n",
      "Step:  139 - loss: 0.0230\n",
      "Step:  140 - loss: 0.0228\n",
      "Step:  141 - loss: 0.0225\n",
      "Step:  142 - loss: 0.0223\n",
      "Step:  143 - loss: 0.0221\n",
      "Step:  144 - loss: 0.0218\n",
      "Step:  145 - loss: 0.0216\n",
      "Step:  146 - loss: 0.0214\n",
      "Step:  147 - loss: 0.0212\n",
      "Step:  148 - loss: 0.0209\n",
      "Step:  149 - loss: 0.0207\n",
      "Step:  150 - loss: 0.0205\n",
      "Step:  151 - loss: 0.0203\n",
      "Step:  152 - loss: 0.0201\n",
      "Step:  153 - loss: 0.0199\n",
      "Step:  154 - loss: 0.0197\n",
      "Step:  155 - loss: 0.0195\n",
      "Step:  156 - loss: 0.0193\n",
      "Step:  157 - loss: 0.0191\n",
      "Step:  158 - loss: 0.0190\n",
      "Step:  159 - loss: 0.0188\n",
      "Step:  160 - loss: 0.0186\n",
      "Step:  161 - loss: 0.0184\n",
      "Step:  162 - loss: 0.0183\n",
      "Step:  163 - loss: 0.0181\n",
      "Step:  164 - loss: 0.0179\n",
      "Step:  165 - loss: 0.0178\n",
      "Step:  166 - loss: 0.0176\n",
      "Step:  167 - loss: 0.0174\n",
      "Step:  168 - loss: 0.0173\n",
      "Step:  169 - loss: 0.0171\n",
      "Step:  170 - loss: 0.0170\n",
      "Step:  171 - loss: 0.0168\n",
      "Step:  172 - loss: 0.0167\n",
      "Step:  173 - loss: 0.0165\n",
      "Step:  174 - loss: 0.0164\n",
      "Step:  175 - loss: 0.0163\n",
      "Step:  176 - loss: 0.0161\n",
      "Step:  177 - loss: 0.0160\n",
      "Step:  178 - loss: 0.0158\n",
      "Step:  179 - loss: 0.0157\n",
      "Step:  180 - loss: 0.0156\n",
      "Step:  181 - loss: 0.0154\n",
      "Step:  182 - loss: 0.0153\n",
      "Step:  183 - loss: 0.0152\n",
      "Step:  184 - loss: 0.0151\n",
      "Step:  185 - loss: 0.0149\n",
      "Step:  186 - loss: 0.0148\n",
      "Step:  187 - loss: 0.0147\n",
      "Step:  188 - loss: 0.0146\n",
      "Step:  189 - loss: 0.0145\n",
      "Step:  190 - loss: 0.0144\n",
      "Step:  191 - loss: 0.0142\n",
      "Step:  192 - loss: 0.0141\n",
      "Step:  193 - loss: 0.0140\n",
      "Step:  194 - loss: 0.0139\n",
      "Step:  195 - loss: 0.0138\n",
      "Step:  196 - loss: 0.0137\n",
      "Step:  197 - loss: 0.0136\n",
      "Step:  198 - loss: 0.0135\n",
      "Step:  199 - loss: 0.0134\n",
      "Step:  200 - loss: 0.0133\n",
      "Step:  201 - loss: 0.0132\n",
      "Step:  202 - loss: 0.0131\n",
      "Step:  203 - loss: 0.0130\n",
      "Step:  204 - loss: 0.0129\n",
      "Step:  205 - loss: 0.0128\n",
      "Step:  206 - loss: 0.0127\n",
      "Step:  207 - loss: 0.0126\n",
      "Step:  208 - loss: 0.0125\n",
      "Step:  209 - loss: 0.0124\n",
      "Step:  210 - loss: 0.0123\n",
      "Step:  211 - loss: 0.0123\n",
      "Step:  212 - loss: 0.0122\n",
      "Step:  213 - loss: 0.0121\n",
      "Step:  214 - loss: 0.0120\n",
      "Step:  215 - loss: 0.0119\n",
      "Step:  216 - loss: 0.0118\n",
      "Step:  217 - loss: 0.0117\n",
      "Step:  218 - loss: 0.0117\n",
      "Step:  219 - loss: 0.0116\n",
      "Step:  220 - loss: 0.0115\n",
      "Step:  221 - loss: 0.0114\n",
      "Step:  222 - loss: 0.0114\n",
      "Step:  223 - loss: 0.0113\n",
      "Step:  224 - loss: 0.0112\n",
      "Step:  225 - loss: 0.0111\n",
      "Step:  226 - loss: 0.0110\n",
      "Step:  227 - loss: 0.0110\n",
      "Step:  228 - loss: 0.0109\n",
      "Step:  229 - loss: 0.0108\n",
      "Step:  230 - loss: 0.0108\n",
      "Step:  231 - loss: 0.0107\n",
      "Step:  232 - loss: 0.0106\n",
      "Step:  233 - loss: 0.0106\n",
      "Step:  234 - loss: 0.0105\n",
      "Step:  235 - loss: 0.0104\n",
      "Step:  236 - loss: 0.0104\n",
      "Step:  237 - loss: 0.0103\n",
      "Step:  238 - loss: 0.0102\n",
      "Step:  239 - loss: 0.0102\n",
      "Step:  240 - loss: 0.0101\n",
      "Step:  241 - loss: 0.0100\n",
      "Step:  242 - loss: 0.0100\n",
      "Step:  243 - loss: 0.0099\n",
      "Step:  244 - loss: 0.0098\n",
      "Step:  245 - loss: 0.0098\n",
      "Step:  246 - loss: 0.0097\n",
      "Step:  247 - loss: 0.0097\n",
      "Step:  248 - loss: 0.0096\n",
      "Step:  249 - loss: 0.0095\n",
      "Step:  250 - loss: 0.0095\n",
      "Step:  251 - loss: 0.0094\n",
      "Step:  252 - loss: 0.0094\n",
      "Step:  253 - loss: 0.0093\n",
      "Step:  254 - loss: 0.0093\n",
      "Step:  255 - loss: 0.0092\n",
      "Step:  256 - loss: 0.0092\n",
      "Step:  257 - loss: 0.0091\n",
      "Step:  258 - loss: 0.0090\n",
      "Step:  259 - loss: 0.0090\n",
      "Step:  260 - loss: 0.0089\n",
      "Step:  261 - loss: 0.0089\n",
      "Step:  262 - loss: 0.0088\n",
      "Step:  263 - loss: 0.0088\n",
      "Step:  264 - loss: 0.0087\n",
      "Step:  265 - loss: 0.0087\n",
      "Step:  266 - loss: 0.0086\n",
      "Step:  267 - loss: 0.0086\n",
      "Step:  268 - loss: 0.0085\n",
      "Step:  269 - loss: 0.0085\n",
      "Step:  270 - loss: 0.0084\n",
      "Step:  271 - loss: 0.0084\n",
      "Step:  272 - loss: 0.0084\n",
      "Step:  273 - loss: 0.0083\n",
      "Step:  274 - loss: 0.0083\n",
      "Step:  275 - loss: 0.0082\n",
      "Step:  276 - loss: 0.0082\n",
      "Step:  277 - loss: 0.0081\n",
      "Step:  278 - loss: 0.0081\n",
      "Step:  279 - loss: 0.0080\n",
      "Step:  280 - loss: 0.0080\n",
      "Step:  281 - loss: 0.0079\n",
      "Step:  282 - loss: 0.0079\n",
      "Step:  283 - loss: 0.0079\n",
      "Step:  284 - loss: 0.0078\n",
      "Step:  285 - loss: 0.0078\n",
      "Step:  286 - loss: 0.0077\n",
      "Step:  287 - loss: 0.0077\n",
      "Step:  288 - loss: 0.0077\n",
      "Step:  289 - loss: 0.0076\n",
      "Step:  290 - loss: 0.0076\n",
      "Step:  291 - loss: 0.0075\n",
      "Step:  292 - loss: 0.0075\n",
      "Step:  293 - loss: 0.0075\n",
      "Step:  294 - loss: 0.0074\n",
      "Step:  295 - loss: 0.0074\n",
      "Step:  296 - loss: 0.0073\n",
      "Step:  297 - loss: 0.0073\n",
      "Step:  298 - loss: 0.0073\n",
      "Step:  299 - loss: 0.0072\n",
      "Step:  300 - loss: 0.0072\n",
      "Step:  301 - loss: 0.0072\n",
      "Step:  302 - loss: 0.0071\n",
      "Step:  303 - loss: 0.0071\n",
      "Step:  304 - loss: 0.0071\n",
      "Step:  305 - loss: 0.0070\n",
      "Step:  306 - loss: 0.0070\n",
      "Step:  307 - loss: 0.0070\n",
      "Step:  308 - loss: 0.0069\n",
      "Step:  309 - loss: 0.0069\n",
      "Step:  310 - loss: 0.0068\n",
      "Step:  311 - loss: 0.0068\n",
      "Step:  312 - loss: 0.0068\n",
      "Step:  313 - loss: 0.0068\n",
      "Step:  314 - loss: 0.0067\n",
      "Step:  315 - loss: 0.0067\n",
      "Step:  316 - loss: 0.0067\n",
      "Step:  317 - loss: 0.0066\n",
      "Step:  318 - loss: 0.0066\n",
      "Step:  319 - loss: 0.0066\n",
      "Step:  320 - loss: 0.0065\n",
      "Step:  321 - loss: 0.0065\n",
      "Step:  322 - loss: 0.0065\n",
      "Step:  323 - loss: 0.0064\n",
      "Step:  324 - loss: 0.0064\n",
      "Step:  325 - loss: 0.0064\n",
      "Step:  326 - loss: 0.0063\n",
      "Step:  327 - loss: 0.0063\n",
      "Step:  328 - loss: 0.0063\n",
      "Step:  329 - loss: 0.0063\n",
      "Step:  330 - loss: 0.0062\n",
      "Step:  331 - loss: 0.0062\n",
      "Step:  332 - loss: 0.0062\n",
      "Step:  333 - loss: 0.0061\n",
      "Step:  334 - loss: 0.0061\n",
      "Step:  335 - loss: 0.0061\n",
      "Step:  336 - loss: 0.0061\n",
      "Step:  337 - loss: 0.0060\n",
      "Step:  338 - loss: 0.0060\n",
      "Step:  339 - loss: 0.0060\n",
      "Step:  340 - loss: 0.0060\n",
      "Step:  341 - loss: 0.0059\n",
      "Step:  342 - loss: 0.0059\n",
      "Step:  343 - loss: 0.0059\n",
      "Step:  344 - loss: 0.0058\n",
      "Step:  345 - loss: 0.0058\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Step:  346 - loss: 0.0058\n",
      "Step:  347 - loss: 0.0058\n",
      "Step:  348 - loss: 0.0057\n",
      "Step:  349 - loss: 0.0057\n",
      "Step:  350 - loss: 0.0057\n",
      "Step:  351 - loss: 0.0057\n",
      "Step:  352 - loss: 0.0056\n",
      "Step:  353 - loss: 0.0056\n",
      "Step:  354 - loss: 0.0056\n",
      "Step:  355 - loss: 0.0056\n",
      "Step:  356 - loss: 0.0055\n",
      "Step:  357 - loss: 0.0055\n",
      "Step:  358 - loss: 0.0055\n",
      "Step:  359 - loss: 0.0055\n",
      "Step:  360 - loss: 0.0055\n",
      "Step:  361 - loss: 0.0054\n",
      "Step:  362 - loss: 0.0054\n",
      "Step:  363 - loss: 0.0054\n",
      "Step:  364 - loss: 0.0054\n",
      "Step:  365 - loss: 0.0053\n",
      "Step:  366 - loss: 0.0053\n",
      "Step:  367 - loss: 0.0053\n",
      "Step:  368 - loss: 0.0053\n",
      "Step:  369 - loss: 0.0053\n",
      "Step:  370 - loss: 0.0052\n",
      "Step:  371 - loss: 0.0052\n",
      "Step:  372 - loss: 0.0052\n",
      "Step:  373 - loss: 0.0052\n",
      "Step:  374 - loss: 0.0051\n",
      "Step:  375 - loss: 0.0051\n",
      "Step:  376 - loss: 0.0051\n",
      "Step:  377 - loss: 0.0051\n",
      "Step:  378 - loss: 0.0051\n",
      "Step:  379 - loss: 0.0050\n",
      "Step:  380 - loss: 0.0050\n",
      "Step:  381 - loss: 0.0050\n",
      "Step:  382 - loss: 0.0050\n",
      "Step:  383 - loss: 0.0050\n",
      "Step:  384 - loss: 0.0049\n",
      "Step:  385 - loss: 0.0049\n",
      "Step:  386 - loss: 0.0049\n",
      "Step:  387 - loss: 0.0049\n",
      "Step:  388 - loss: 0.0049\n",
      "Step:  389 - loss: 0.0048\n",
      "Step:  390 - loss: 0.0048\n",
      "Step:  391 - loss: 0.0048\n",
      "Step:  392 - loss: 0.0048\n",
      "Step:  393 - loss: 0.0048\n",
      "Step:  394 - loss: 0.0048\n",
      "Step:  395 - loss: 0.0047\n",
      "Step:  396 - loss: 0.0047\n",
      "Step:  397 - loss: 0.0047\n",
      "Step:  398 - loss: 0.0047\n",
      "Step:  399 - loss: 0.0047\n",
      "Step:  400 - loss: 0.0046\n",
      "Step:  401 - loss: 0.0046\n",
      "Step:  402 - loss: 0.0046\n",
      "Step:  403 - loss: 0.0046\n",
      "Step:  404 - loss: 0.0046\n",
      "Step:  405 - loss: 0.0046\n",
      "Step:  406 - loss: 0.0045\n",
      "Step:  407 - loss: 0.0045\n",
      "Step:  408 - loss: 0.0045\n",
      "Step:  409 - loss: 0.0045\n",
      "Step:  410 - loss: 0.0045\n",
      "Step:  411 - loss: 0.0045\n",
      "Step:  412 - loss: 0.0044\n",
      "Step:  413 - loss: 0.0044\n",
      "Step:  414 - loss: 0.0044\n",
      "Step:  415 - loss: 0.0044\n",
      "Step:  416 - loss: 0.0044\n",
      "Step:  417 - loss: 0.0044\n",
      "Step:  418 - loss: 0.0043\n",
      "Step:  419 - loss: 0.0043\n",
      "Step:  420 - loss: 0.0043\n",
      "Step:  421 - loss: 0.0043\n",
      "Step:  422 - loss: 0.0043\n",
      "Step:  423 - loss: 0.0043\n",
      "Step:  424 - loss: 0.0042\n",
      "Step:  425 - loss: 0.0042\n",
      "Step:  426 - loss: 0.0042\n",
      "Step:  427 - loss: 0.0042\n",
      "Step:  428 - loss: 0.0042\n",
      "Step:  429 - loss: 0.0042\n",
      "Step:  430 - loss: 0.0042\n",
      "Step:  431 - loss: 0.0041\n",
      "Step:  432 - loss: 0.0041\n",
      "Step:  433 - loss: 0.0041\n",
      "Step:  434 - loss: 0.0041\n",
      "Step:  435 - loss: 0.0041\n",
      "Step:  436 - loss: 0.0041\n",
      "Step:  437 - loss: 0.0041\n",
      "Step:  438 - loss: 0.0040\n",
      "Step:  439 - loss: 0.0040\n",
      "Step:  440 - loss: 0.0040\n",
      "Step:  441 - loss: 0.0040\n",
      "Step:  442 - loss: 0.0040\n",
      "Step:  443 - loss: 0.0040\n",
      "Step:  444 - loss: 0.0040\n",
      "Step:  445 - loss: 0.0039\n",
      "Step:  446 - loss: 0.0039\n",
      "Step:  447 - loss: 0.0039\n",
      "Step:  448 - loss: 0.0039\n",
      "Step:  449 - loss: 0.0039\n",
      "Step:  450 - loss: 0.0039\n",
      "Step:  451 - loss: 0.0039\n",
      "Step:  452 - loss: 0.0038\n",
      "Step:  453 - loss: 0.0038\n",
      "Step:  454 - loss: 0.0038\n",
      "Step:  455 - loss: 0.0038\n",
      "Step:  456 - loss: 0.0038\n",
      "Step:  457 - loss: 0.0038\n",
      "Step:  458 - loss: 0.0038\n",
      "Step:  459 - loss: 0.0038\n",
      "Step:  460 - loss: 0.0037\n",
      "Step:  461 - loss: 0.0037\n",
      "Step:  462 - loss: 0.0037\n",
      "Step:  463 - loss: 0.0037\n",
      "Step:  464 - loss: 0.0037\n",
      "Step:  465 - loss: 0.0037\n",
      "Step:  466 - loss: 0.0037\n",
      "Step:  467 - loss: 0.0037\n",
      "Step:  468 - loss: 0.0036\n",
      "Step:  469 - loss: 0.0036\n",
      "Step:  470 - loss: 0.0036\n",
      "Step:  471 - loss: 0.0036\n",
      "Step:  472 - loss: 0.0036\n",
      "Step:  473 - loss: 0.0036\n",
      "Step:  474 - loss: 0.0036\n",
      "Step:  475 - loss: 0.0036\n",
      "Step:  476 - loss: 0.0035\n",
      "Step:  477 - loss: 0.0035\n",
      "Step:  478 - loss: 0.0035\n",
      "Step:  479 - loss: 0.0035\n",
      "Step:  480 - loss: 0.0035\n",
      "Step:  481 - loss: 0.0035\n",
      "Step:  482 - loss: 0.0035\n",
      "Step:  483 - loss: 0.0035\n",
      "Step:  484 - loss: 0.0035\n",
      "Step:  485 - loss: 0.0034\n",
      "Step:  486 - loss: 0.0034\n",
      "Step:  487 - loss: 0.0034\n",
      "Step:  488 - loss: 0.0034\n",
      "Step:  489 - loss: 0.0034\n",
      "Step:  490 - loss: 0.0034\n",
      "Step:  491 - loss: 0.0034\n",
      "Step:  492 - loss: 0.0034\n",
      "Step:  493 - loss: 0.0034\n",
      "Step:  494 - loss: 0.0034\n",
      "Step:  495 - loss: 0.0033\n",
      "Step:  496 - loss: 0.0033\n",
      "Step:  497 - loss: 0.0033\n",
      "Step:  498 - loss: 0.0033\n",
      "Step:  499 - loss: 0.0033\n",
      "Step:  500 - loss: 0.0033\n",
      "Step:  501 - loss: 0.0033\n",
      "Step:  502 - loss: 0.0033\n",
      "Step:  503 - loss: 0.0033\n",
      "Step:  504 - loss: 0.0032\n",
      "Step:  505 - loss: 0.0032\n",
      "Step:  506 - loss: 0.0032\n",
      "Step:  507 - loss: 0.0032\n",
      "Step:  508 - loss: 0.0032\n",
      "Step:  509 - loss: 0.0032\n",
      "Step:  510 - loss: 0.0032\n",
      "Step:  511 - loss: 0.0032\n",
      "Step:  512 - loss: 0.0032\n",
      "Step:  513 - loss: 0.0032\n",
      "Step:  514 - loss: 0.0032\n",
      "Step:  515 - loss: 0.0031\n",
      "Step:  516 - loss: 0.0031\n",
      "Step:  517 - loss: 0.0031\n",
      "Step:  518 - loss: 0.0031\n",
      "Step:  519 - loss: 0.0031\n",
      "Step:  520 - loss: 0.0031\n",
      "Step:  521 - loss: 0.0031\n",
      "Step:  522 - loss: 0.0031\n",
      "Step:  523 - loss: 0.0031\n",
      "Step:  524 - loss: 0.0031\n",
      "Step:  525 - loss: 0.0030\n",
      "Step:  526 - loss: 0.0030\n",
      "Step:  527 - loss: 0.0030\n",
      "Step:  528 - loss: 0.0030\n",
      "Step:  529 - loss: 0.0030\n",
      "Step:  530 - loss: 0.0030\n",
      "Step:  531 - loss: 0.0030\n",
      "Step:  532 - loss: 0.0030\n",
      "Step:  533 - loss: 0.0030\n",
      "Step:  534 - loss: 0.0030\n",
      "Step:  535 - loss: 0.0030\n",
      "Step:  536 - loss: 0.0030\n",
      "Step:  537 - loss: 0.0029\n",
      "Step:  538 - loss: 0.0029\n",
      "Step:  539 - loss: 0.0029\n",
      "Step:  540 - loss: 0.0029\n",
      "Step:  541 - loss: 0.0029\n",
      "Step:  542 - loss: 0.0029\n",
      "Step:  543 - loss: 0.0029\n",
      "Step:  544 - loss: 0.0029\n",
      "Step:  545 - loss: 0.0029\n",
      "Step:  546 - loss: 0.0029\n",
      "Step:  547 - loss: 0.0029\n",
      "Step:  548 - loss: 0.0029\n",
      "Step:  549 - loss: 0.0028\n",
      "Step:  550 - loss: 0.0028\n",
      "Step:  551 - loss: 0.0028\n",
      "Step:  552 - loss: 0.0028\n",
      "Step:  553 - loss: 0.0028\n",
      "Step:  554 - loss: 0.0028\n",
      "Step:  555 - loss: 0.0028\n",
      "Step:  556 - loss: 0.0028\n",
      "Step:  557 - loss: 0.0028\n",
      "Step:  558 - loss: 0.0028\n",
      "Step:  559 - loss: 0.0028\n",
      "Step:  560 - loss: 0.0028\n",
      "Step:  561 - loss: 0.0027\n",
      "Step:  562 - loss: 0.0027\n",
      "Step:  563 - loss: 0.0027\n",
      "Step:  564 - loss: 0.0027\n",
      "Step:  565 - loss: 0.0027\n",
      "Step:  566 - loss: 0.0027\n",
      "Step:  567 - loss: 0.0027\n",
      "Step:  568 - loss: 0.0027\n",
      "Step:  569 - loss: 0.0027\n",
      "Step:  570 - loss: 0.0027\n",
      "Step:  571 - loss: 0.0027\n",
      "Step:  572 - loss: 0.0027\n",
      "Step:  573 - loss: 0.0027\n",
      "Step:  574 - loss: 0.0027\n",
      "Step:  575 - loss: 0.0026\n",
      "Step:  576 - loss: 0.0026\n",
      "Step:  577 - loss: 0.0026\n",
      "Step:  578 - loss: 0.0026\n",
      "Step:  579 - loss: 0.0026\n",
      "Step:  580 - loss: 0.0026\n",
      "Step:  581 - loss: 0.0026\n",
      "Step:  582 - loss: 0.0026\n",
      "Step:  583 - loss: 0.0026\n",
      "Step:  584 - loss: 0.0026\n",
      "Step:  585 - loss: 0.0026\n",
      "Step:  586 - loss: 0.0026\n",
      "Step:  587 - loss: 0.0026\n",
      "Step:  588 - loss: 0.0026\n",
      "Step:  589 - loss: 0.0025\n",
      "Step:  590 - loss: 0.0025\n",
      "Step:  591 - loss: 0.0025\n",
      "Step:  592 - loss: 0.0025\n",
      "Step:  593 - loss: 0.0025\n",
      "Step:  594 - loss: 0.0025\n",
      "Step:  595 - loss: 0.0025\n",
      "Step:  596 - loss: 0.0025\n",
      "Step:  597 - loss: 0.0025\n",
      "Step:  598 - loss: 0.0025\n",
      "Step:  599 - loss: 0.0025\n",
      "Step:  600 - loss: 0.0025\n",
      "Step:  601 - loss: 0.0025\n",
      "Step:  602 - loss: 0.0025\n",
      "Step:  603 - loss: 0.0025\n",
      "Step:  604 - loss: 0.0024\n",
      "Step:  605 - loss: 0.0024\n",
      "Step:  606 - loss: 0.0024\n",
      "Step:  607 - loss: 0.0024\n",
      "Step:  608 - loss: 0.0024\n",
      "Step:  609 - loss: 0.0024\n",
      "Step:  610 - loss: 0.0024\n",
      "Step:  611 - loss: 0.0024\n",
      "Step:  612 - loss: 0.0024\n",
      "Step:  613 - loss: 0.0024\n",
      "Step:  614 - loss: 0.0024\n",
      "Step:  615 - loss: 0.0024\n",
      "Step:  616 - loss: 0.0024\n",
      "Step:  617 - loss: 0.0024\n",
      "Step:  618 - loss: 0.0024\n",
      "Step:  619 - loss: 0.0024\n",
      "Step:  620 - loss: 0.0023\n",
      "Step:  621 - loss: 0.0023\n",
      "Step:  622 - loss: 0.0023\n",
      "Step:  623 - loss: 0.0023\n",
      "Step:  624 - loss: 0.0023\n",
      "Step:  625 - loss: 0.0023\n",
      "Step:  626 - loss: 0.0023\n",
      "Step:  627 - loss: 0.0023\n",
      "Step:  628 - loss: 0.0023\n",
      "Step:  629 - loss: 0.0023\n",
      "Step:  630 - loss: 0.0023\n",
      "Step:  631 - loss: 0.0023\n",
      "Step:  632 - loss: 0.0023\n",
      "Step:  633 - loss: 0.0023\n",
      "Step:  634 - loss: 0.0023\n",
      "Step:  635 - loss: 0.0023\n",
      "Step:  636 - loss: 0.0023\n",
      "Step:  637 - loss: 0.0022\n",
      "Step:  638 - loss: 0.0022\n",
      "Step:  639 - loss: 0.0022\n",
      "Step:  640 - loss: 0.0022\n",
      "Step:  641 - loss: 0.0022\n",
      "Step:  642 - loss: 0.0022\n",
      "Step:  643 - loss: 0.0022\n",
      "Step:  644 - loss: 0.0022\n",
      "Step:  645 - loss: 0.0022\n",
      "Step:  646 - loss: 0.0022\n",
      "Step:  647 - loss: 0.0022\n",
      "Step:  648 - loss: 0.0022\n",
      "Step:  649 - loss: 0.0022\n",
      "Step:  650 - loss: 0.0022\n",
      "Step:  651 - loss: 0.0022\n",
      "Step:  652 - loss: 0.0022\n",
      "Step:  653 - loss: 0.0022\n",
      "Step:  654 - loss: 0.0022\n",
      "Step:  655 - loss: 0.0022\n",
      "Step:  656 - loss: 0.0021\n",
      "Step:  657 - loss: 0.0021\n",
      "Step:  658 - loss: 0.0021\n",
      "Step:  659 - loss: 0.0021\n",
      "Step:  660 - loss: 0.0021\n",
      "Step:  661 - loss: 0.0021\n",
      "Step:  662 - loss: 0.0021\n",
      "Step:  663 - loss: 0.0021\n",
      "Step:  664 - loss: 0.0021\n",
      "Step:  665 - loss: 0.0021\n",
      "Step:  666 - loss: 0.0021\n",
      "Step:  667 - loss: 0.0021\n",
      "Step:  668 - loss: 0.0021\n",
      "Step:  669 - loss: 0.0021\n",
      "Step:  670 - loss: 0.0021\n",
      "Step:  671 - loss: 0.0021\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Step:  672 - loss: 0.0021\n",
      "Step:  673 - loss: 0.0021\n",
      "Step:  674 - loss: 0.0021\n",
      "Step:  675 - loss: 0.0021\n",
      "Step:  676 - loss: 0.0020\n",
      "Step:  677 - loss: 0.0020\n",
      "Step:  678 - loss: 0.0020\n",
      "Step:  679 - loss: 0.0020\n",
      "Step:  680 - loss: 0.0020\n",
      "Step:  681 - loss: 0.0020\n",
      "Step:  682 - loss: 0.0020\n",
      "Step:  683 - loss: 0.0020\n",
      "Step:  684 - loss: 0.0020\n",
      "Step:  685 - loss: 0.0020\n",
      "Step:  686 - loss: 0.0020\n",
      "Step:  687 - loss: 0.0020\n",
      "Step:  688 - loss: 0.0020\n",
      "Step:  689 - loss: 0.0020\n",
      "Step:  690 - loss: 0.0020\n",
      "Step:  691 - loss: 0.0020\n",
      "Step:  692 - loss: 0.0020\n",
      "Step:  693 - loss: 0.0020\n",
      "Step:  694 - loss: 0.0020\n",
      "Step:  695 - loss: 0.0020\n",
      "Step:  696 - loss: 0.0020\n",
      "Step:  697 - loss: 0.0019\n",
      "Step:  698 - loss: 0.0019\n",
      "Step:  699 - loss: 0.0019\n",
      "Step:  700 - loss: 0.0019\n",
      "Step:  701 - loss: 0.0019\n",
      "Step:  702 - loss: 0.0019\n",
      "Step:  703 - loss: 0.0019\n",
      "Step:  704 - loss: 0.0019\n",
      "Step:  705 - loss: 0.0019\n",
      "Step:  706 - loss: 0.0019\n",
      "Step:  707 - loss: 0.0019\n",
      "Step:  708 - loss: 0.0019\n",
      "Step:  709 - loss: 0.0019\n",
      "Step:  710 - loss: 0.0019\n",
      "Step:  711 - loss: 0.0019\n",
      "Step:  712 - loss: 0.0019\n",
      "Step:  713 - loss: 0.0019\n",
      "Step:  714 - loss: 0.0019\n",
      "Step:  715 - loss: 0.0019\n",
      "Step:  716 - loss: 0.0019\n",
      "Step:  717 - loss: 0.0019\n",
      "Step:  718 - loss: 0.0019\n",
      "Step:  719 - loss: 0.0019\n",
      "Step:  720 - loss: 0.0019\n",
      "Step:  721 - loss: 0.0018\n",
      "Step:  722 - loss: 0.0018\n",
      "Step:  723 - loss: 0.0018\n",
      "Step:  724 - loss: 0.0018\n",
      "Step:  725 - loss: 0.0018\n",
      "Step:  726 - loss: 0.0018\n",
      "Step:  727 - loss: 0.0018\n",
      "Step:  728 - loss: 0.0018\n",
      "Step:  729 - loss: 0.0018\n",
      "Step:  730 - loss: 0.0018\n",
      "Step:  731 - loss: 0.0018\n",
      "Step:  732 - loss: 0.0018\n",
      "Step:  733 - loss: 0.0018\n",
      "Step:  734 - loss: 0.0018\n",
      "Step:  735 - loss: 0.0018\n",
      "Step:  736 - loss: 0.0018\n",
      "Step:  737 - loss: 0.0018\n",
      "Step:  738 - loss: 0.0018\n",
      "Step:  739 - loss: 0.0018\n",
      "Step:  740 - loss: 0.0018\n",
      "Step:  741 - loss: 0.0018\n",
      "Step:  742 - loss: 0.0018\n",
      "Step:  743 - loss: 0.0018\n",
      "Step:  744 - loss: 0.0018\n",
      "Step:  745 - loss: 0.0018\n",
      "Step:  746 - loss: 0.0017\n",
      "Step:  747 - loss: 0.0017\n",
      "Step:  748 - loss: 0.0017\n",
      "Step:  749 - loss: 0.0017\n",
      "Step:  750 - loss: 0.0017\n",
      "Step:  751 - loss: 0.0017\n",
      "Step:  752 - loss: 0.0017\n",
      "Step:  753 - loss: 0.0017\n",
      "Step:  754 - loss: 0.0017\n",
      "Step:  755 - loss: 0.0017\n",
      "Step:  756 - loss: 0.0017\n",
      "Step:  757 - loss: 0.0017\n",
      "Step:  758 - loss: 0.0017\n",
      "Step:  759 - loss: 0.0017\n",
      "Step:  760 - loss: 0.0017\n",
      "Step:  761 - loss: 0.0017\n",
      "Step:  762 - loss: 0.0017\n",
      "Step:  763 - loss: 0.0017\n",
      "Step:  764 - loss: 0.0017\n",
      "Step:  765 - loss: 0.0017\n",
      "Step:  766 - loss: 0.0017\n",
      "Step:  767 - loss: 0.0017\n",
      "Step:  768 - loss: 0.0017\n",
      "Step:  769 - loss: 0.0017\n",
      "Step:  770 - loss: 0.0017\n",
      "Step:  771 - loss: 0.0017\n",
      "Step:  772 - loss: 0.0017\n",
      "Step:  773 - loss: 0.0017\n",
      "Step:  774 - loss: 0.0016\n",
      "Step:  775 - loss: 0.0016\n",
      "Step:  776 - loss: 0.0016\n",
      "Step:  777 - loss: 0.0016\n",
      "Step:  778 - loss: 0.0016\n",
      "Step:  779 - loss: 0.0016\n",
      "Step:  780 - loss: 0.0016\n",
      "Step:  781 - loss: 0.0016\n",
      "Step:  782 - loss: 0.0016\n",
      "Step:  783 - loss: 0.0016\n",
      "Step:  784 - loss: 0.0016\n",
      "Step:  785 - loss: 0.0016\n",
      "Step:  786 - loss: 0.0016\n",
      "Step:  787 - loss: 0.0016\n",
      "Step:  788 - loss: 0.0016\n",
      "Step:  789 - loss: 0.0016\n",
      "Step:  790 - loss: 0.0016\n",
      "Step:  791 - loss: 0.0016\n",
      "Step:  792 - loss: 0.0016\n",
      "Step:  793 - loss: 0.0016\n",
      "Step:  794 - loss: 0.0016\n",
      "Step:  795 - loss: 0.0016\n",
      "Step:  796 - loss: 0.0016\n",
      "Step:  797 - loss: 0.0016\n",
      "Step:  798 - loss: 0.0016\n",
      "Step:  799 - loss: 0.0016\n",
      "Step:  800 - loss: 0.0016\n",
      "Step:  801 - loss: 0.0016\n",
      "Step:  802 - loss: 0.0016\n",
      "Step:  803 - loss: 0.0016\n",
      "Step:  804 - loss: 0.0015\n",
      "Step:  805 - loss: 0.0015\n",
      "Step:  806 - loss: 0.0015\n",
      "Step:  807 - loss: 0.0015\n",
      "Step:  808 - loss: 0.0015\n",
      "Step:  809 - loss: 0.0015\n",
      "Step:  810 - loss: 0.0015\n",
      "Step:  811 - loss: 0.0015\n",
      "Step:  812 - loss: 0.0015\n",
      "Step:  813 - loss: 0.0015\n",
      "Step:  814 - loss: 0.0015\n",
      "Step:  815 - loss: 0.0015\n",
      "Step:  816 - loss: 0.0015\n",
      "Step:  817 - loss: 0.0015\n",
      "Step:  818 - loss: 0.0015\n",
      "Step:  819 - loss: 0.0015\n",
      "Step:  820 - loss: 0.0015\n",
      "Step:  821 - loss: 0.0015\n",
      "Step:  822 - loss: 0.0015\n",
      "Step:  823 - loss: 0.0015\n",
      "Step:  824 - loss: 0.0015\n",
      "Step:  825 - loss: 0.0015\n",
      "Step:  826 - loss: 0.0015\n",
      "Step:  827 - loss: 0.0015\n",
      "Step:  828 - loss: 0.0015\n",
      "Step:  829 - loss: 0.0015\n",
      "Step:  830 - loss: 0.0015\n",
      "Step:  831 - loss: 0.0015\n",
      "Step:  832 - loss: 0.0015\n",
      "Step:  833 - loss: 0.0015\n",
      "Step:  834 - loss: 0.0015\n",
      "Step:  835 - loss: 0.0015\n",
      "Step:  836 - loss: 0.0015\n",
      "Step:  837 - loss: 0.0015\n",
      "Step:  838 - loss: 0.0014\n",
      "Step:  839 - loss: 0.0014\n",
      "Step:  840 - loss: 0.0014\n",
      "Step:  841 - loss: 0.0014\n",
      "Step:  842 - loss: 0.0014\n",
      "Step:  843 - loss: 0.0014\n",
      "Step:  844 - loss: 0.0014\n",
      "Step:  845 - loss: 0.0014\n",
      "Step:  846 - loss: 0.0014\n",
      "Step:  847 - loss: 0.0014\n",
      "Step:  848 - loss: 0.0014\n",
      "Step:  849 - loss: 0.0014\n",
      "Step:  850 - loss: 0.0014\n",
      "Step:  851 - loss: 0.0014\n",
      "Step:  852 - loss: 0.0014\n",
      "Step:  853 - loss: 0.0014\n",
      "Step:  854 - loss: 0.0014\n",
      "Step:  855 - loss: 0.0014\n",
      "Step:  856 - loss: 0.0014\n",
      "Step:  857 - loss: 0.0014\n",
      "Step:  858 - loss: 0.0014\n",
      "Step:  859 - loss: 0.0014\n",
      "Step:  860 - loss: 0.0014\n",
      "Step:  861 - loss: 0.0014\n",
      "Step:  862 - loss: 0.0014\n",
      "Step:  863 - loss: 0.0014\n",
      "Step:  864 - loss: 0.0014\n",
      "Step:  865 - loss: 0.0014\n",
      "Step:  866 - loss: 0.0014\n",
      "Step:  867 - loss: 0.0014\n",
      "Step:  868 - loss: 0.0014\n",
      "Step:  869 - loss: 0.0014\n",
      "Step:  870 - loss: 0.0014\n",
      "Step:  871 - loss: 0.0014\n",
      "Step:  872 - loss: 0.0014\n",
      "Step:  873 - loss: 0.0014\n",
      "Step:  874 - loss: 0.0014\n",
      "Step:  875 - loss: 0.0014\n",
      "Step:  876 - loss: 0.0013\n",
      "Step:  877 - loss: 0.0013\n",
      "Step:  878 - loss: 0.0013\n",
      "Step:  879 - loss: 0.0013\n",
      "Step:  880 - loss: 0.0013\n",
      "Step:  881 - loss: 0.0013\n",
      "Step:  882 - loss: 0.0013\n",
      "Step:  883 - loss: 0.0013\n",
      "Step:  884 - loss: 0.0013\n",
      "Step:  885 - loss: 0.0013\n",
      "Step:  886 - loss: 0.0013\n",
      "Step:  887 - loss: 0.0013\n",
      "Step:  888 - loss: 0.0013\n",
      "Step:  889 - loss: 0.0013\n",
      "Step:  890 - loss: 0.0013\n",
      "Step:  891 - loss: 0.0013\n",
      "Step:  892 - loss: 0.0013\n",
      "Step:  893 - loss: 0.0013\n",
      "Step:  894 - loss: 0.0013\n",
      "Step:  895 - loss: 0.0013\n",
      "Step:  896 - loss: 0.0013\n",
      "Step:  897 - loss: 0.0013\n",
      "Step:  898 - loss: 0.0013\n",
      "Step:  899 - loss: 0.0013\n",
      "Step:  900 - loss: 0.0013\n",
      "Step:  901 - loss: 0.0013\n",
      "Step:  902 - loss: 0.0013\n",
      "Step:  903 - loss: 0.0013\n",
      "Step:  904 - loss: 0.0013\n",
      "Step:  905 - loss: 0.0013\n",
      "Step:  906 - loss: 0.0013\n",
      "Step:  907 - loss: 0.0013\n",
      "Step:  908 - loss: 0.0013\n",
      "Step:  909 - loss: 0.0013\n",
      "Step:  910 - loss: 0.0013\n",
      "Step:  911 - loss: 0.0013\n",
      "Step:  912 - loss: 0.0013\n",
      "Step:  913 - loss: 0.0013\n",
      "Step:  914 - loss: 0.0013\n",
      "Step:  915 - loss: 0.0013\n",
      "Step:  916 - loss: 0.0013\n",
      "Step:  917 - loss: 0.0013\n",
      "Step:  918 - loss: 0.0012\n",
      "Step:  919 - loss: 0.0012\n",
      "Step:  920 - loss: 0.0012\n",
      "Step:  921 - loss: 0.0012\n",
      "Step:  922 - loss: 0.0012\n",
      "Step:  923 - loss: 0.0012\n",
      "Step:  924 - loss: 0.0012\n",
      "Step:  925 - loss: 0.0012\n",
      "Step:  926 - loss: 0.0012\n",
      "Step:  927 - loss: 0.0012\n",
      "Step:  928 - loss: 0.0012\n",
      "Step:  929 - loss: 0.0012\n",
      "Step:  930 - loss: 0.0012\n",
      "Step:  931 - loss: 0.0012\n",
      "Step:  932 - loss: 0.0012\n",
      "Step:  933 - loss: 0.0012\n",
      "Step:  934 - loss: 0.0012\n",
      "Step:  935 - loss: 0.0012\n",
      "Step:  936 - loss: 0.0012\n",
      "Step:  937 - loss: 0.0012\n",
      "Step:  938 - loss: 0.0012\n",
      "Step:  939 - loss: 0.0012\n",
      "Step:  940 - loss: 0.0012\n",
      "Step:  941 - loss: 0.0012\n",
      "Step:  942 - loss: 0.0012\n",
      "Step:  943 - loss: 0.0012\n",
      "Step:  944 - loss: 0.0012\n",
      "Step:  945 - loss: 0.0012\n",
      "Step:  946 - loss: 0.0012\n",
      "Step:  947 - loss: 0.0012\n",
      "Step:  948 - loss: 0.0012\n",
      "Step:  949 - loss: 0.0012\n",
      "Step:  950 - loss: 0.0012\n",
      "Step:  951 - loss: 0.0012\n",
      "Step:  952 - loss: 0.0012\n",
      "Step:  953 - loss: 0.0012\n",
      "Step:  954 - loss: 0.0012\n",
      "Step:  955 - loss: 0.0012\n",
      "Step:  956 - loss: 0.0012\n",
      "Step:  957 - loss: 0.0012\n",
      "Step:  958 - loss: 0.0012\n",
      "Step:  959 - loss: 0.0012\n",
      "Step:  960 - loss: 0.0012\n",
      "Step:  961 - loss: 0.0012\n",
      "Step:  962 - loss: 0.0012\n",
      "Step:  963 - loss: 0.0012\n",
      "Step:  964 - loss: 0.0012\n",
      "Step:  965 - loss: 0.0011\n",
      "Step:  966 - loss: 0.0011\n",
      "Step:  967 - loss: 0.0011\n",
      "Step:  968 - loss: 0.0011\n",
      "Step:  969 - loss: 0.0011\n",
      "Step:  970 - loss: 0.0011\n",
      "Step:  971 - loss: 0.0011\n",
      "Step:  972 - loss: 0.0011\n",
      "Step:  973 - loss: 0.0011\n",
      "Step:  974 - loss: 0.0011\n",
      "Step:  975 - loss: 0.0011\n",
      "Step:  976 - loss: 0.0011\n",
      "Step:  977 - loss: 0.0011\n",
      "Step:  978 - loss: 0.0011\n",
      "Step:  979 - loss: 0.0011\n",
      "Step:  980 - loss: 0.0011\n",
      "Step:  981 - loss: 0.0011\n",
      "Step:  982 - loss: 0.0011\n",
      "Step:  983 - loss: 0.0011\n",
      "Step:  984 - loss: 0.0011\n",
      "Step:  985 - loss: 0.0011\n",
      "Step:  986 - loss: 0.0011\n",
      "Step:  987 - loss: 0.0011\n",
      "Step:  988 - loss: 0.0011\n",
      "Step:  989 - loss: 0.0011\n",
      "Step:  990 - loss: 0.0011\n",
      "Step:  991 - loss: 0.0011\n",
      "Step:  992 - loss: 0.0011\n",
      "Step:  993 - loss: 0.0011\n",
      "Step:  994 - loss: 0.0011\n",
      "Step:  995 - loss: 0.0011\n",
      "Step:  996 - loss: 0.0011\n",
      "Step:  997 - loss: 0.0011\n",
      "Step:  998 - loss: 0.0011\n",
      "Step:  999 - loss: 0.0011\n",
      "Step: 1000 - loss: 0.0011\n"
     ]
    }
   ],
   "source": [
    "# Define random tensors for the inputs and outputs\n",
    "x = torch.randn(32, 784, requires_grad=True)\n",
    "y = torch.randint(low=0, high=10, size=(32,))\n",
    "\n",
    "\n",
    "\n",
    "# Define the model, using the Sequential class\n",
    "model = torch.nn.Sequential(\n",
    "    torch.nn.Linear(784, 100),\n",
    "    torch.nn.Sigmoid(),\n",
    "    torch.nn.Linear(100, 10),\n",
    "    torch.nn.LogSoftmax(dim=1)\n",
    ")\n",
    "\n",
    "# Define the optimizer and loss function\n",
    "optimizer = torch.optim.Adam(model.parameters())\n",
    "loss_fn = torch.nn.NLLLoss()\n",
    "\n",
    "for step in range(1000):\n",
    "    # Make predictions by forward propagation\n",
    "    y_hat = model(x)\n",
    "    # Calculate the loss\n",
    "    loss = loss_fn(y_hat, y)\n",
    "    # Zero-out the gradient before performing a backward pass\n",
    "    optimizer.zero_grad()\n",
    "    # Compute the gradients w.r.t. the loss\n",
    "    loss.backward()\n",
    "    # Print the results\n",
    "    print('Step: {:4d} - loss: {:0.4f}'.format(step+1, loss.item()))\n",
    "    # Update the model parameters\n",
    "    optimizer.step()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
